#pragma once
#include <string>
#include <vector>
#include <core/container/SHash.h>
#include "../bondlib.h"

struct DealIndex{
	std::string		id;
	DealIndex() :id(""){}
	DealIndex(const char* str) :id(str?str:""){}
	DealIndex(const DealIndex& di) :id(di.id){}
	DealIndex& operator=(const DealIndex& di){ id = di.id; return *this; }
	bool operator==(const DealIndex& di)const{ return id == di.id; }
	bool operator<(const DealIndex& di)const{ return id < di.id; }
	unsigned int GetHash()const{ return qb::base::GetFastHash(id.c_str(),id.size(), 0); }
};
class S_BONDLIB_EXPORT IRecordMap {
public:
	class Callback{
	public:
		virtual void OnEach(const DealIndex& id, const void* record){}
	};
	virtual ~IRecordMap(){}
	virtual void Enumerate(Callback* cb)const=0;
	virtual const void* FindRecord(const DealIndex& id)const=0;
	virtual void Add(const DealIndex& id, const void* record)=0;
	virtual void Remove(const DealIndex& id)=0;
};
class S_BONDLIB_EXPORT IBatchedKeys{

public:
	virtual void GetKeys(std::vector<DealIndex>& allkeys)const=0;
	virtual int GetBatchId()const = 0;
	virtual void SetBatchId(int id) = 0;
};
class S_BONDLIB_EXPORT IRealTimeDealModel{
public:
	virtual void ResetKeys(){};
	virtual int GetCount()const = 0;
	virtual int64_t GetState()const = 0;
	virtual void SetState(int64_t state) = 0;
	virtual int GetBatchId()const = 0;
	virtual void SetBatchId(int id) = 0;
	virtual void AddFlash(int id, const void* record) = 0;
	virtual void AddRecord(int id, const void* record) = 0;
	virtual void ClearFlash() = 0;
	virtual int  GetKeys(int pos, int count, void* keys) = 0;
	virtual bool IsMultiEnable()const = 0;
	virtual void CheckMulti(const IRecordMap* records) = 0;
	virtual void SyncKeys(const IBatchedKeys* keys, const IRecordMap* records) = 0;
	virtual void StartCompare(const IRecordMap* records) = 0;
	virtual void EndCompare(const IRecordMap* records) = 0;
};